
from feature import Feature, FeatureParser, registerFeatureParserClass

class FastaFeature(Feature):
    def getDetails(self):
        cols = self.content.strip().split("\t")
        self.seq = cols[-1]
        return self

class FastaFeatureParser(FeatureParser):
    '''
    Parser for lines in fasta-features.txt files.
    Parses tab-separated string:
    chr1    201    250    ccctaaccctaaccctaaccctaaccctaacccctaaccctaaccctaaa
    '''
    def parse(self, line):
        if line == None or line.startswith("#"): return None
        cols = line.strip().split("\t")
        if len(cols)<4: return None
        return FastaFeature(cols[0], cols[1], cols[2], line)
    def getMaxFeatureSize(self):
        return 100

registerFeatureParserClass("fasta-features", FastaFeatureParser)

